{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7b791098",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>foo</td>\n",
       "      <td>one</td>\n",
       "      <td>-0.569425</td>\n",
       "      <td>1.263913</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>bar</td>\n",
       "      <td>one</td>\n",
       "      <td>-0.614456</td>\n",
       "      <td>0.344549</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>foo</td>\n",
       "      <td>two</td>\n",
       "      <td>0.802644</td>\n",
       "      <td>0.795926</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>bar</td>\n",
       "      <td>three</td>\n",
       "      <td>0.850531</td>\n",
       "      <td>1.085517</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>foo</td>\n",
       "      <td>two</td>\n",
       "      <td>-0.050964</td>\n",
       "      <td>0.917726</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>bar</td>\n",
       "      <td>two</td>\n",
       "      <td>0.192486</td>\n",
       "      <td>-0.404803</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>foo</td>\n",
       "      <td>one</td>\n",
       "      <td>0.597233</td>\n",
       "      <td>0.116309</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>foo</td>\n",
       "      <td>three</td>\n",
       "      <td>-1.207328</td>\n",
       "      <td>-1.043646</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     A      B         C         D\n",
       "0  foo    one -0.569425  1.263913\n",
       "1  bar    one -0.614456  0.344549\n",
       "2  foo    two  0.802644  0.795926\n",
       "3  bar  three  0.850531  1.085517\n",
       "4  foo    two -0.050964  0.917726\n",
       "5  bar    two  0.192486 -0.404803\n",
       "6  foo    one  0.597233  0.116309\n",
       "7  foo  three -1.207328 -1.043646"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "df =pd.DataFrame({'A':['foo','bar','foo','bar',\n",
    "                      'foo','bar','foo','foo'],\n",
    "                 'B':['one','one','two','three',\n",
    "                     'two','two','one','three'],\n",
    "                 'C': np.random.randn(8),\n",
    "                 'D': np.random.randn(8)})\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f3d4d163",
   "metadata": {},
   "outputs": [],
   "source": [
    "grouped =df.groupby('A')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9fb80bef",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>bar</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>foo</th>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     B  C  D\n",
       "A           \n",
       "bar  3  3  3\n",
       "foo  5  5  5"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "5fb7c8de",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">bar</th>\n",
       "      <th>one</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>three</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>two</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">foo</th>\n",
       "      <th>one</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>three</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>two</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           C  D\n",
       "A   B          \n",
       "bar one    1  1\n",
       "    three  1  1\n",
       "    two    1  1\n",
       "foo one    2  2\n",
       "    three  1  1\n",
       "    two    2  2"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped =df.groupby(['A','B'])\n",
    "grouped.count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9dae64dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    1\n",
       "b    3\n",
       "Name: 0, dtype: int64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def get_letter_type(letter):\n",
    "    if letter.lower() in 'aeiou':\n",
    "        return 'a'\n",
    "    else:\n",
    "        return 'b'\n",
    "    \n",
    "grouped = df.groupby(get_letter_type,axis=1)\n",
    "grouped.count().iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "41cc3eaf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8    1\n",
       "7    2\n",
       "5    3\n",
       "8    1\n",
       "7    2\n",
       "5    3\n",
       "dtype: int64"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = pd.Series([1,2,3,1,2,3],[8,7,5,8,7,5])\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "7de8e516",
   "metadata": {},
   "outputs": [],
   "source": [
    "grouped =s.groupby(level =0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "f95423b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5    3\n",
       "7    2\n",
       "8    1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.first()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "1cc1b00a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5    3\n",
       "7    2\n",
       "8    1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.last()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "68150e40",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5    6\n",
       "7    4\n",
       "8    2\n",
       "dtype: int64"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "ea869bf5",
   "metadata": {},
   "outputs": [],
   "source": [
    "grouped = s.groupby(level = 0,sort=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "1c3d5f05",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8    1\n",
       "7    2\n",
       "5    3\n",
       "dtype: int64"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.first()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "44fc4cd7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>X</th>\n",
       "      <th>Y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>B</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>A</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>B</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   X  Y\n",
       "0  A  1\n",
       "1  B  2\n",
       "2  A  3\n",
       "3  B  4"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = pd.DataFrame({'X':['A','B','A','B'],'Y':[1,2,3,4]})\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "edfb8515",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>X</th>\n",
       "      <th>Y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>B</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>B</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   X  Y\n",
       "1  B  2\n",
       "3  B  4"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.groupby(['X']).get_group('B')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "cd17cb7e",
   "metadata": {},
   "outputs": [],
   "source": [
    "arrays = [['bar','bar','baz','baz','foo','foo','qux','qux'],\n",
    "         ['one','two','one','two','one','two','one','two']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "cf2cb712",
   "metadata": {},
   "outputs": [],
   "source": [
    "index = pd.MultiIndex.from_arrays(arrays,names =['first','second'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "06c42750",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "first  second\n",
       "bar    one       0.546507\n",
       "       two       0.757515\n",
       "baz    one       0.405036\n",
       "       two       0.310591\n",
       "foo    one       0.419998\n",
       "       two       0.809977\n",
       "qux    one       0.942680\n",
       "       two       0.520283\n",
       "dtype: float64"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = pd.Series(np.random.random(8),index =index)\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "b9569e83",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "first\n",
       "bar    1.304022\n",
       "baz    0.715628\n",
       "foo    1.229975\n",
       "qux    1.462963\n",
       "dtype: float64"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped = s.groupby(level = 0)\n",
    "grouped.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "a4e2b471",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "second\n",
       "one    2.314221\n",
       "two    2.398367\n",
       "dtype: float64"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped = s.groupby(level = 1)\n",
    "grouped.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "eaf1c209",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "first\n",
       "bar    1.304022\n",
       "baz    0.715628\n",
       "foo    1.229975\n",
       "qux    1.462963\n",
       "dtype: float64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped = s.groupby(level = 'first')\n",
    "grouped.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "2d13ac76",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>foo</td>\n",
       "      <td>one</td>\n",
       "      <td>-0.569425</td>\n",
       "      <td>1.263913</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>bar</td>\n",
       "      <td>one</td>\n",
       "      <td>-0.614456</td>\n",
       "      <td>0.344549</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>foo</td>\n",
       "      <td>two</td>\n",
       "      <td>0.802644</td>\n",
       "      <td>0.795926</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>bar</td>\n",
       "      <td>three</td>\n",
       "      <td>0.850531</td>\n",
       "      <td>1.085517</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>foo</td>\n",
       "      <td>two</td>\n",
       "      <td>-0.050964</td>\n",
       "      <td>0.917726</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>bar</td>\n",
       "      <td>two</td>\n",
       "      <td>0.192486</td>\n",
       "      <td>-0.404803</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>foo</td>\n",
       "      <td>one</td>\n",
       "      <td>0.597233</td>\n",
       "      <td>0.116309</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>foo</td>\n",
       "      <td>three</td>\n",
       "      <td>-1.207328</td>\n",
       "      <td>-1.043646</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     A      B         C         D\n",
       "0  foo    one -0.569425  1.263913\n",
       "1  bar    one -0.614456  0.344549\n",
       "2  foo    two  0.802644  0.795926\n",
       "3  bar  three  0.850531  1.085517\n",
       "4  foo    two -0.050964  0.917726\n",
       "5  bar    two  0.192486 -0.404803\n",
       "6  foo    one  0.597233  0.116309\n",
       "7  foo  three -1.207328 -1.043646"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "e9bb6f03",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">bar</th>\n",
       "      <th>one</th>\n",
       "      <td>-0.614456</td>\n",
       "      <td>0.344549</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>three</th>\n",
       "      <td>0.850531</td>\n",
       "      <td>1.085517</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>two</th>\n",
       "      <td>0.192486</td>\n",
       "      <td>-0.404803</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">foo</th>\n",
       "      <th>one</th>\n",
       "      <td>0.027807</td>\n",
       "      <td>1.380222</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>three</th>\n",
       "      <td>-1.207328</td>\n",
       "      <td>-1.043646</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>two</th>\n",
       "      <td>0.751680</td>\n",
       "      <td>1.713652</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  C         D\n",
       "A   B                        \n",
       "bar one   -0.614456  0.344549\n",
       "    three  0.850531  1.085517\n",
       "    two    0.192486 -0.404803\n",
       "foo one    0.027807  1.380222\n",
       "    three -1.207328 -1.043646\n",
       "    two    0.751680  1.713652"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped =df.groupby(['A','B'])\n",
    "grouped.aggregate(np.sum)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "30ecc6f2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>bar</td>\n",
       "      <td>one</td>\n",
       "      <td>-0.614456</td>\n",
       "      <td>0.344549</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>bar</td>\n",
       "      <td>three</td>\n",
       "      <td>0.850531</td>\n",
       "      <td>1.085517</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>bar</td>\n",
       "      <td>two</td>\n",
       "      <td>0.192486</td>\n",
       "      <td>-0.404803</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>foo</td>\n",
       "      <td>one</td>\n",
       "      <td>0.027807</td>\n",
       "      <td>1.380222</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>foo</td>\n",
       "      <td>three</td>\n",
       "      <td>-1.207328</td>\n",
       "      <td>-1.043646</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>foo</td>\n",
       "      <td>two</td>\n",
       "      <td>0.751680</td>\n",
       "      <td>1.713652</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     A      B         C         D\n",
       "0  bar    one -0.614456  0.344549\n",
       "1  bar  three  0.850531  1.085517\n",
       "2  bar    two  0.192486 -0.404803\n",
       "3  foo    one  0.027807  1.380222\n",
       "4  foo  three -1.207328 -1.043646\n",
       "5  foo    two  0.751680  1.713652"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped =df.groupby(['A','B'],as_index =False)\n",
    "grouped.aggregate(np.sum)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "34514332",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>bar</td>\n",
       "      <td>one</td>\n",
       "      <td>-0.614456</td>\n",
       "      <td>0.344549</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>bar</td>\n",
       "      <td>three</td>\n",
       "      <td>0.850531</td>\n",
       "      <td>1.085517</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>bar</td>\n",
       "      <td>two</td>\n",
       "      <td>0.192486</td>\n",
       "      <td>-0.404803</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>foo</td>\n",
       "      <td>one</td>\n",
       "      <td>0.027807</td>\n",
       "      <td>1.380222</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>foo</td>\n",
       "      <td>three</td>\n",
       "      <td>-1.207328</td>\n",
       "      <td>-1.043646</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>foo</td>\n",
       "      <td>two</td>\n",
       "      <td>0.751680</td>\n",
       "      <td>1.713652</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     A      B         C         D\n",
       "0  bar    one -0.614456  0.344549\n",
       "1  bar  three  0.850531  1.085517\n",
       "2  bar    two  0.192486 -0.404803\n",
       "3  foo    one  0.027807  1.380222\n",
       "4  foo  three -1.207328 -1.043646\n",
       "5  foo    two  0.751680  1.713652"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(['A','B']).sum().reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "0708c090",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>size</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>bar</td>\n",
       "      <td>one</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>bar</td>\n",
       "      <td>three</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>bar</td>\n",
       "      <td>two</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>foo</td>\n",
       "      <td>one</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>foo</td>\n",
       "      <td>three</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>foo</td>\n",
       "      <td>two</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     A      B  size\n",
       "0  bar    one     1\n",
       "1  bar  three     1\n",
       "2  bar    two     1\n",
       "3  foo    one     2\n",
       "4  foo  three     1\n",
       "5  foo    two     2"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.size()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "3f44c3ad",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th colspan=\"8\" halign=\"left\">C</th>\n",
       "      <th colspan=\"8\" halign=\"left\">D</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.0</td>\n",
       "      <td>-0.614456</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-0.614456</td>\n",
       "      <td>-0.614456</td>\n",
       "      <td>-0.614456</td>\n",
       "      <td>-0.614456</td>\n",
       "      <td>-0.614456</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.344549</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.344549</td>\n",
       "      <td>0.344549</td>\n",
       "      <td>0.344549</td>\n",
       "      <td>0.344549</td>\n",
       "      <td>0.344549</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.850531</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.850531</td>\n",
       "      <td>0.850531</td>\n",
       "      <td>0.850531</td>\n",
       "      <td>0.850531</td>\n",
       "      <td>0.850531</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.085517</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.085517</td>\n",
       "      <td>1.085517</td>\n",
       "      <td>1.085517</td>\n",
       "      <td>1.085517</td>\n",
       "      <td>1.085517</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.192486</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.192486</td>\n",
       "      <td>0.192486</td>\n",
       "      <td>0.192486</td>\n",
       "      <td>0.192486</td>\n",
       "      <td>0.192486</td>\n",
       "      <td>1.0</td>\n",
       "      <td>-0.404803</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-0.404803</td>\n",
       "      <td>-0.404803</td>\n",
       "      <td>-0.404803</td>\n",
       "      <td>-0.404803</td>\n",
       "      <td>-0.404803</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.0</td>\n",
       "      <td>0.013904</td>\n",
       "      <td>0.824952</td>\n",
       "      <td>-0.569425</td>\n",
       "      <td>-0.277761</td>\n",
       "      <td>0.013904</td>\n",
       "      <td>0.305568</td>\n",
       "      <td>0.597233</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.690111</td>\n",
       "      <td>0.811478</td>\n",
       "      <td>0.116309</td>\n",
       "      <td>0.403210</td>\n",
       "      <td>0.690111</td>\n",
       "      <td>0.977012</td>\n",
       "      <td>1.263913</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1.0</td>\n",
       "      <td>-1.207328</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-1.207328</td>\n",
       "      <td>-1.207328</td>\n",
       "      <td>-1.207328</td>\n",
       "      <td>-1.207328</td>\n",
       "      <td>-1.207328</td>\n",
       "      <td>1.0</td>\n",
       "      <td>-1.043646</td>\n",
       "      <td>NaN</td>\n",
       "      <td>-1.043646</td>\n",
       "      <td>-1.043646</td>\n",
       "      <td>-1.043646</td>\n",
       "      <td>-1.043646</td>\n",
       "      <td>-1.043646</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      C                                                                        \\\n",
       "  count      mean       std       min       25%       50%       75%       max   \n",
       "0   1.0 -0.614456       NaN -0.614456 -0.614456 -0.614456 -0.614456 -0.614456   \n",
       "1   1.0  0.850531       NaN  0.850531  0.850531  0.850531  0.850531  0.850531   \n",
       "2   1.0  0.192486       NaN  0.192486  0.192486  0.192486  0.192486  0.192486   \n",
       "3   2.0  0.013904  0.824952 -0.569425 -0.277761  0.013904  0.305568  0.597233   \n",
       "4   1.0 -1.207328       NaN -1.207328 -1.207328 -1.207328 -1.207328 -1.207328   \n",
       "\n",
       "      D                                                                        \n",
       "  count      mean       std       min       25%       50%       75%       max  \n",
       "0   1.0  0.344549       NaN  0.344549  0.344549  0.344549  0.344549  0.344549  \n",
       "1   1.0  1.085517       NaN  1.085517  1.085517  1.085517  1.085517  1.085517  \n",
       "2   1.0 -0.404803       NaN -0.404803 -0.404803 -0.404803 -0.404803 -0.404803  \n",
       "3   2.0  0.690111  0.811478  0.116309  0.403210  0.690111  0.977012  1.263913  \n",
       "4   1.0 -1.043646       NaN -1.043646 -1.043646 -1.043646 -1.043646 -1.043646  "
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped.describe().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "e55ccc4e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sum</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>bar</th>\n",
       "      <td>0.428562</td>\n",
       "      <td>0.142854</td>\n",
       "      <td>0.733754</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>foo</th>\n",
       "      <td>-0.427841</td>\n",
       "      <td>-0.085568</td>\n",
       "      <td>0.828975</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          sum      mean       std\n",
       "A                                \n",
       "bar  0.428562  0.142854  0.733754\n",
       "foo -0.427841 -0.085568  0.828975"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "grouped = df.groupby('A')\n",
    "grouped['C'].agg([np.sum,np.mean,np.std])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "73aebbd5",
   "metadata": {},
   "outputs": [
    {
     "ename": "SpecificationError",
     "evalue": "nested renamer is not supported",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mSpecificationError\u001b[0m                        Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[51], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m grouped[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mC\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39magg({\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mres_sum\u001b[39m\u001b[38;5;124m'\u001b[39m:np\u001b[38;5;241m.\u001b[39msum,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mres_mean\u001b[39m\u001b[38;5;124m'\u001b[39m:np\u001b[38;5;241m.\u001b[39mmean,\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mres_std\u001b[39m\u001b[38;5;124m'\u001b[39m:np\u001b[38;5;241m.\u001b[39mstd})\n",
      "File \u001b[1;32mD:\\ProgramData\\Anaconda3\\Lib\\site-packages\\pandas\\core\\groupby\\generic.py:281\u001b[0m, in \u001b[0;36mSeriesGroupBy.aggregate\u001b[1;34m(self, func, engine, engine_kwargs, *args, **kwargs)\u001b[0m\n\u001b[0;32m    277\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(func, abc\u001b[38;5;241m.\u001b[39mIterable):\n\u001b[0;32m    278\u001b[0m     \u001b[38;5;66;03m# Catch instances of lists / tuples\u001b[39;00m\n\u001b[0;32m    279\u001b[0m     \u001b[38;5;66;03m# but not the class list / tuple itself.\u001b[39;00m\n\u001b[0;32m    280\u001b[0m     func \u001b[38;5;241m=\u001b[39m maybe_mangle_lambdas(func)\n\u001b[1;32m--> 281\u001b[0m     ret \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_aggregate_multiple_funcs(func)\n\u001b[0;32m    282\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m relabeling:\n\u001b[0;32m    283\u001b[0m         \u001b[38;5;66;03m# columns is not narrowed by mypy from relabeling flag\u001b[39;00m\n\u001b[0;32m    284\u001b[0m         \u001b[38;5;28;01massert\u001b[39;00m columns \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m  \u001b[38;5;66;03m# for mypy\u001b[39;00m\n",
      "File \u001b[1;32mD:\\ProgramData\\Anaconda3\\Lib\\site-packages\\pandas\\core\\groupby\\generic.py:317\u001b[0m, in \u001b[0;36mSeriesGroupBy._aggregate_multiple_funcs\u001b[1;34m(self, arg)\u001b[0m\n\u001b[0;32m    311\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_aggregate_multiple_funcs\u001b[39m(\u001b[38;5;28mself\u001b[39m, arg) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m DataFrame:\n\u001b[0;32m    312\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(arg, \u001b[38;5;28mdict\u001b[39m):\n\u001b[0;32m    313\u001b[0m \n\u001b[0;32m    314\u001b[0m         \u001b[38;5;66;03m# show the deprecation, but only if we\u001b[39;00m\n\u001b[0;32m    315\u001b[0m         \u001b[38;5;66;03m# have not shown a higher level one\u001b[39;00m\n\u001b[0;32m    316\u001b[0m         \u001b[38;5;66;03m# GH 15931\u001b[39;00m\n\u001b[1;32m--> 317\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m SpecificationError(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnested renamer is not supported\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m    319\u001b[0m     \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28many\u001b[39m(\u001b[38;5;28misinstance\u001b[39m(x, (\u001b[38;5;28mtuple\u001b[39m, \u001b[38;5;28mlist\u001b[39m)) \u001b[38;5;28;01mfor\u001b[39;00m x \u001b[38;5;129;01min\u001b[39;00m arg):\n\u001b[0;32m    320\u001b[0m         arg \u001b[38;5;241m=\u001b[39m [(x, x) \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(x, (\u001b[38;5;28mtuple\u001b[39m, \u001b[38;5;28mlist\u001b[39m)) \u001b[38;5;28;01melse\u001b[39;00m x \u001b[38;5;28;01mfor\u001b[39;00m x \u001b[38;5;129;01min\u001b[39;00m arg]\n",
      "\u001b[1;31mSpecificationError\u001b[0m: nested renamer is not supported"
     ]
    }
   ],
   "source": [
    "grouped['C'].agg({'res_sum':np.sum,'res_mean':np.mean,'res_std':np.std})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2eec8fac",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
